import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import Report from '../components/report/Report';
import { routedCategory } from '../actions/CalcRiskAction';

const mapStateToProps = (state, ownProps) => {
  return ({
    ...state.bodyData,
    fiveHealthHabit: {
      ...state.report.fiveHealthHabit.initialRisk.probability,
    },
    cerebralStroke: {
      ...state.report.cerebralStroke.initialRisk.probability,
    },
    cardiacInfarction: {
      ...state.report.cardiacInfarction.initialRisk.probability,
    },
    gastricCancer: {
      ...state.report.gastricCancer.initialRisk.probability,
    },
    colorectalCancer: {
      ...state.report.colorectalCancer.initialRisk.probability,
    },
    defaultCategory: state.category.routedCategory,
  });
}

const mapDispatchToProps = (dispatch) => ({
  onAction: category => {
    dispatch(routedCategory(category));
    dispatch(push(`/report_${category}`));
  },
  onCancel: () => {
    dispatch(push('/input'));
  },
});

export default connect(mapStateToProps, mapDispatchToProps)(Report)
